<template>
  <!-- 统计的form表单 -->
      <el-form ref="elForm" :model="formData" size="medium" label-width="1.3rem">
        <el-row>
          <el-col :span="5">
            <el-row>
              <el-form-item label="电压：">
                <el-select
                  v-model="formData.voltageLevel"
                  placeholder="请选择"
                  clearable
                  :style="{width: '100%'}"
                >
                  <el-option
                    v-for="(item,index) in voltage"
                    :key="index"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-row>
          </el-col>
          <el-col :span="5">
            <el-row>
              <el-form-item label="厂家名称：">
                <el-select
                  v-model="formData.keyFirm"
                  placeholder="请选择"
                  clearable
                  :style="{width: '100%'}"
                >
                  <el-option
                    v-for="(item,index) in  manufacturerName"
                    :key="index"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-row>
          </el-col>
          <el-col :span="5">
            <el-row>
              <el-form-item label="解锁原因：">
                <el-select
                  v-model="formData.reasonCode"
                  placeholder="请选择"
                  clearable
                  :style="{width: '100%'}"
                >
                  <el-option
                    v-for="(item,index) in unlockReason"
                    :key="index"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-row>
          </el-col>
          <el-col :span="3">
            <div class="btn-ground centerbox">
              <el-button icon="iconfont iconsousuo" type="primary" @click="queryForm">查询</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { JointInspectionModule } from "@/store/modules/JointInspection";
@Component({
  components: {
  },
})
export default class FiveKeyDetails extends Vue {
  // 电压
  voltage: Array<object> = [];
  // 厂家名称
  manufacturerName: Array<object> = [];
  //   解锁原因
  unlockReason: Array<object> = [
    {
      value: "",
      label: "全部",
    },
    {
      value: "1",
      label: "紧急解锁",
    },
    {
      value: "2",
      label: "防误装置异常解锁",
    },
    {
      value: "3",
      label: "电气设备异常解锁",
    },
    {
      value: "4",
      label: "电气设备检修解锁",
    },
    {
      value: "5",
      label: "归还钥匙",
    },
  ];
  formData = {
    voltageLevel: "",
    keyFirm: "",
    reasonCode: "",
  };

  get CompanyList() {
    let CompanyList = JointInspectionModule.CompanyList || [];
    return CompanyList;
  }

  // 电压等级
  getVoltageLevel() {
    var localCity = "";
    if (this.CompanyList && this.CompanyList[0] && this.CompanyList[0].code) {
      localCity = this.CompanyList[0].code;
    } else {
      localCity = "8a1ea5c64bdebad1014bdebc6047087b";
    }
    var params = {
      localCity: localCity,
    };
    console.log(1111);
    
    (this as any).$services
      .getVoltageLevel({ data: params })
      .then((result: any) => {
        if (result.data) {
          var data = [];
          result.data.map((k) => {
            data.push({
              value: k.code,
              label: k.name,
            });
          });
          this.voltage = data;
        }
      })
      .catch((err: object) => {
        console.log(err);
      });
  }
    // 厂家
  getCj() {
    var localCity = "";
    if (this.CompanyList && this.CompanyList[0] && this.CompanyList[0].code) {
      localCity = this.CompanyList[0].code;
    } else {
      localCity = "8a1ea5c64bdebad1014bdebc6047087b";
    }
    var params = {
      localCity: localCity,
    };
    (this as any).$services
      .getCj({ data: params })
      .then((result: any) => {
        if (result.data) {
          var data = [];
          result.data.map((k) => {
            data.push({
              value: k.CODE,
              label: k.NAME,
            });
          });
          this.manufacturerName = data;
        }
      })
      .catch((err: object) => {
        console.log(err);
      });
  }
  // 查询
  queryForm() {
    // console.log(this.formData);
    this.$emit("queryForm", this.formData);
  }
  mounted(){
    this.getVoltageLevel()
    this.getCj()
  }
}
</script>

<style lang="scss" scoped>

</style>